function x = quality(actual, expected)
% Given two N x [x y width height] matrices 
% returns the sets' resemblance factor defined as 
% number of cases similar enough (difference between
% every parameter no bigger that 0.1*expected_width

if size(actual) ~= size(expected)
    error('Actual and expected matrices should be of the same size')
end
num_fitting = 0;
num_cases = size(expected, 1);
for i = 1:num_cases
    exp_width = expected(i, 3);
    delta = 0.1 * exp_width;
    if sum((expected(i,:) - actual(i,:)) < delta) == 4
        num_fitting = num_fitting + 1;
    end
end
x = num_fitting / num_cases;

